<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h2>history2</h2>
<button>后退</button>
<button>前进</button>
<a href="./09-history3.html">history3</a>
<script>

    document.getElementsByTagName('button')[0].onclick = function () {
        // 后退
        // window.history.back()
        window.history.go(-1)  //  负数后退  数值标识前进或后退的步数
    }
    document.getElementsByTagName('button')[1].onclick = function () {
        // 前进
        // window.history.forward()
        window.history.go(1)  //  正数前进
    }

</script>
</body>
</html>